package com.warrantyhotel.android.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.warrantyhotel.android.R;

public class RedeemCodeAdapter extends ArrayAdapter<String> {

	private Context context;

	public RedeemCodeAdapter(Context context, int textViewResourceId, String[] items) {
		super(context, textViewResourceId, items);
		this.context = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.redeem_code_item, null);
		}
		ImageView imageView = (ImageView) v.findViewById(R.id.item_image_code);
		TextView tt = (TextView) v.findViewById(R.id.item_text_title_redeem);
		TextView bt = (TextView) v.findViewById(R.id.item_text_value);

		switch (position) {
		case 0:
			imageView.setImageResource(R.drawable.icn_code_type);
			tt.setText(context.getString(R.string.type_the_code));
			bt.setText(context.getString(R.string.type_code_manualy));
			break;
		case 1:
			imageView.setImageResource(R.drawable.icn_qr);
			tt.setText(context.getString(R.string.qr_code_reader));
			bt.setText(context.getString(R.string.launch_qr_code_scanner));
			break;
		default:
			break;
		}
		return v;
	}

}
